package gui;

import java.awt.Button;
import java.awt.GridLayout;
import java.io.IOException;

import javax.swing.JEditorPane;
import javax.swing.JPanel;

import logic.Courselist;

public class CourselistPanel extends JPanel {

	private String uri;

	public CourselistPanel(Courselist courselist) {
		setLayout(new GridLayout(0,1));
		for (String s:courselist.getList()) {
			add(new Button(s));
		}
	}
	
	public CourselistPanel() {
		uri = new Courselist().getUrl();
	}

	public JEditorPane get() {
		try {
			JEditorPane editorPane = new JEditorPane(uri);
			editorPane.setEditable(false);
			return editorPane;
		} catch (IOException e) {
			e.printStackTrace();
			return null;
		}	
	}

}
